package org.andcool.animation.ease;

/**
 * @author Joosun
 * @since 2011-5-8
 */
public class EaseBack extends BaseEase
{
	public EaseBack(final EasingMode pEasingMode)
	{
		super(pEasingMode);
	}

	@Override
	protected float getEaseInInterpolation(final float pPercentage)
	{
		return pPercentage * pPercentage * ((1.70158f + 1) * pPercentage - 1.70158f);
	}

	@Override
	protected float getEaseOutInterpolation(float pPercentage)
	{
		return (pPercentage -= 1) * pPercentage * ((1.70158f + 1) * pPercentage + 1.70158f) + 1;
	}

	@Override
	protected float getEaseInOutInterpolation(float pPercentage)
	{
		float s = 1.70158f;

		pPercentage *= 2;

		if (pPercentage < 1)
		{
			return 0.5f * (pPercentage * pPercentage * (((s *= (1.525f)) + 1) * pPercentage - s));
		}

		return 0.5f * ((pPercentage -= 2) * pPercentage * (((s *= (1.525f)) + 1) * pPercentage + s) + 2);
	}
}